package com.doge.walknovel.api.model

import com.doge.walknovel.business.novel.NovelChapterPosHelper
import com.doge.walknovel.utils.isNullOrZero

data class NovelDetailInfo(
    val novelId: Int,
    val coverUrl: String?,
    val title: String?,
    val description: String?,
    val author: String?,
    val language: String?,
    val score: Float?,
    val tabName: List<String>?,
    val likeList: List<NovelInfo>?,
    val scoreFlag: Int?,
    val totalCommentCount: Int?,
    val recentChapterId: Int?,
    val firstChapterId: Int?,
    val chapterCount: Int?,
    val progress: Float?,
) {
    val readerChapterId: Int? get() {
        val cacheChapterId = NovelChapterPosHelper.loadCache(novelId)
        if (!cacheChapterId.isNullOrZero()) return cacheChapterId
        if (!recentChapterId.isNullOrZero()) return recentChapterId
        return firstChapterId
    }
}